package com.killgun.level;

import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.asset.AssetManager;
import com.jme3.scene.Spatial;
import com.killgun.MainApp;
import com.killgun.physics.PhysicsAppState;

/**
 *
 * @author Austin Allman
 */
public class LevelAppState extends AbstractAppState {

    private LevelLoader levelLoader;
    private Spatial currentLevel;
    private MainApp main;
    private boolean physicsAttached;

    @Override
    public void initialize(AppStateManager stateManager, Application app) {
        super.initialize(stateManager, app);
        main = (MainApp) app;
        AssetManager assetManager = main.getAssetManager();
        levelLoader = new LevelLoader(assetManager);
        currentLevel = levelLoader.loadLevel(Level.ONE);
//        main.getRootNode().attachChild(currentLevel);
//        PhysicsAppState.addSolid(currentLevel);
    }

    public Spatial getCurrentLevel() {
        return currentLevel;
    }

    /* @Override
     public void update(float tpf) {
     super.update(tpf);
     if (!physicsAttached) {
     // main.getStateManager().getState(PhysicsAppState.class).addSolid(currentLevel);
     physicsAttached = true;
     }
     }*/
}